package io.coderyeah.ymcc.feign.fallback;

import feign.hystrix.FallbackFactory;
import io.coderyeah.ymcc.constant.YmccConstants;
import io.coderyeah.ymcc.domain.CourseDoc;
import io.coderyeah.ymcc.enums.YmccSystemError;
import io.coderyeah.ymcc.feign.client.SearchServiceClient;
import io.coderyeah.ymcc.result.JSONResult;

/**
 * @author lqs
 * @date 2022/10/22 22:56
 */
public class SearchClientFallback implements FallbackFactory<SearchServiceClient> {

    @Override
    public SearchServiceClient create(Throwable throwable) {
        return new SearchServiceClient() {
            @Override
            public JSONResult save(CourseDoc doc) {
                throwable.printStackTrace();
                return JSONResult.error(YmccSystemError.SEARCH_SERVICE_ERROR);
            }

            @Override
            public JSONResult deleteById(Long id) {
                throwable.printStackTrace();
                return JSONResult.error(YmccSystemError.SEARCH_SERVICE_ERROR);
            }
        };
    }
}
